#ifndef F_CAHouseKC_h
#define F_CAHouseKC_h

// ***********************************************************************

// class EDROOMTopContext

// ***********************************************************************



class EDROOMTopContext {

protected:

enum EDROOMCAHouseKSignal { EDROOMSignalTimeout, EDROOMSignalDestroy, SHouseKStatus, SSSIStarted, SSGIStarted, SToStandBy, SToEmergency, SStartSGIComm, SEndSGIComm, SStartSSIComm, SEndSSIComm };


	friend class CAHouseK;

	CAHouseK &EDROOMcomponent;

	CEDROOMMessage * &Msg;

	CEDROOMMessage * &MsgBack;

	//Ports

	CEDROOMInterface & PlannerHousek;
	CEDROOMTimingInterface & Timer;

	enum edroomStateId{I, Ready, Emergency};

	enum IdTrans{Init, DoHouseKeeping, StartSSIComm, EndSSIComm, StartSGIComm, EndSGIComm, ToEmergency, ToStandBy,  EDROOMMEMORIA };

	//Constantes

	const TEDROOMByte CEmergencyMask;
	const TEDROOMByte CSGIOnMask;
	const TEDROOMByte CSSIOnMask;


	//Variables

	TEDROOMUInt32 &VNextHouseKUniTimeSecns;
	TEDROOMByte &VStatus;


	//Pool

	class CEDROOMPOOLTEDROOMByte:public CEDROOMProtectedMemoryPool {
		public:
		CEDROOMPOOLTEDROOMByte(TEDROOMUInt32 elemCount,TEDROOMByte *pMem, TEDROOMBool *pMarks);
		TEDROOMByte	* AllocData();
	};
	CEDROOMPOOLTEDROOMByte	& EDROOMPoolTEDROOMByte;


	// CONSTRUCTORES

	EDROOMTopContext (CAHouseK &act, TEDROOMUInt32 & EDROOMpVarVNextHouseKUniTimeSecns, TEDROOMByte & EDROOMpVarVStatus, CEDROOMPOOLTEDROOMByte & EDROOMpPoolTEDROOMByte );

	EDROOMTopContext ( EDROOMTopContext &contex );

public:

	bool EDROOMSearchContextTrans(TEDROOMTransId &edroomCurrentTrans);

	void EDROOMNuevoMens () { EDROOMcomponent.EDROOMNewMsg(); }

	// Funciones Definidas por el usuario

	void	FDoHouseK();

	void	FEndSGIComm();

	void	FEndSSIComm();

	void	FInit();

	void	FStartSGIComm();

	void	FStartSSIComm();

	void	FToEmergency();

	void	FToStandBy();

};

// ***********************************************************************

// class EDROOMTopState

// ***********************************************************************



class EDROOMTopState : public EDROOMTopContext {

protected:



	EDROOMTopContext::edroomStateId edroomCurrentState;

	EDROOMTopContext::edroomStateId edroomNextState;

	//Variables

	TEDROOMUInt32 VNextHouseKUniTimeSecns;
	TEDROOMByte VStatus;


	//Pools

	CEDROOMPOOLTEDROOMByte	EDROOMPoolTEDROOMByte;


public:

	// CONSTRUCTOR

	EDROOMTopState (CAHouseK &act, CEDROOMMemory *pEDROOMMemory  );


	// EDROOMBehaviour**********************************************

	void EDROOMBehaviour();

	// Inicio**********************************************

	void EDROOMInicio();

	// ***********************************************************************

	// SubEstado Inicial 

	// ***********************************************************************



	TEDROOMTransId EDROOMIllegada();

	// ***********************************************************************

	// SubEstado Hoja Ready

	// ***********************************************************************



	TEDROOMTransId EDROOMReadyllegada();

	// ***********************************************************************

	// SubEstado Hoja Emergency

	// ***********************************************************************



	TEDROOMTransId EDROOMEmergencyllegada();

};


#endif
